package com.googlecode.garbagecan.jsonstudy.json;

import java.util.Calendar;

import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;

import com.googlecode.garbagecan.jsonstudy.User;

public class JSONXML {

	public static void main(String[] args) throws Exception {
		User user = new User();
		user.setUsername("Mandy");
		user.setPassword("Mandy");
		user.setBirthday(Calendar.getInstance().getTime());
		JSONObject jsonObj = JSONObject.fromObject(user);
		System.out.println(jsonObj);
		
		XMLSerializer xmlSerializer = new XMLSerializer();
		String xml = xmlSerializer.write(jsonObj);  
		System.out.println(xml);
		
		jsonObj = (JSONObject)xmlSerializer.read(xml);
		System.out.println(jsonObj);
	}
}
